package com.atguigu.rabbitmq.demo.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;



import java.util.Date;

/*队列TTL 消费者*/
@Slf4j
@Component //这不是service也不是controller也不是mapper，所以用@Component注解注入到spring容器中
public class DeadLetterQueueConsumer {
    //接收消息
    @RabbitListener(queues = "QD")
    public void receiveD(Message message, Channel channel) throws Exception{//Message和Channel导包不要导错了
        String msg=new String(message.getBody());
        log.info("当前时间：{},收到死信队列信息{}", new Date().toString(), msg);

    }
}
